/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TEMP;

import Table.TableInfoCenter;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Administrator
 */
public class TableValues extends AbstractTableModel{

//    public final static int FIRST_NAME = 0;
//    public final static int LAST_NAME = 1;
//    public final static int DATE_OF_BIRTH = 2;
//    public final static int ACCOUNT_BALANCE = 3;
//    public final static int GENDER = 4;
//
//    public final static boolean GENDER_MALE = true;
//    public final static boolean GENDER_FEMALE = false;

//    public Object[][] values = {
//        {
//            "ASFD", "SDF",
//            new GregorianCalendar(1962, Calendar.FEBRUARY, 20).getTime(),
//            new Float(1234.56), new Boolean (GENDER_MALE)
//        }, {
//            "asdf", "asfd",
//            new GregorianCalendar(1962, Calendar.FEBRUARY, 20).getTime(),
//            new Float(1234.56), new Boolean (GENDER_MALE)
//        }, {
//            "asdf", "asfd",
//            new GregorianCalendar(1962, Calendar.FEBRUARY, 20).getTime(),
//            new Float(1234.56), new Boolean (GENDER_MALE)
//        }, {
//            "asdf", "asfd",
//            new GregorianCalendar(1962, Calendar.FEBRUARY, 20).getTime(),
//            new Float(1234.56), new Boolean (GENDER_MALE)
//        },{
//            "asdf", "asfd",
//            new GregorianCalendar(1962, Calendar.FEBRUARY, 20).getTime(),
//            new Float(1234.56), new Boolean (GENDER_MALE)
//        }
//    };
//    public Object[][][] values;
    private String[] columnNames = new String[100];
    private TableInfoCenter TIC;

    public TableValues(TableInfoCenter TIC) {
        this.TIC = TIC;
        for(int i = 0; i < TIC.ColumnInfo.length; ++i){
            columnNames[i] = TIC.ColumnInfo[i].getName();
        }
        
    }

    public static TableValues getInstance() {
        return TableValuesHolder.INSTANCE;
    }

    private TableValues() {
        //throw new UnsupportedOperationException("Not yet implemented");
    }

    public int getRowCount() {
        //throw new UnsupportedOperationException("Not supported yet.");
        return TIC.InfoSet.size();
    }

    public int getColumnCount() {
        //throw new UnsupportedOperationException("Not supported yet.");
        return TIC.ColumnInfo.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        //throw new UnsupportedOperationException("Not supported yet.");
//        Class c = values[rowIndex][columnIndex].getClass();
//        c.get
        return TIC.InfoSet.get(rowIndex)[columnIndex];
    }

    private static class TableValuesHolder {
        private static final TableValues INSTANCE = new TableValues();
    }

    @Override
    public String getColumnName(int column){
        return columnNames[column];
    }

    @Override
    public void setValueAt(Object value, int rowIndex, int columnIndex) {
        Object[] temp = TIC.InfoSet.get(rowIndex);
        temp[columnIndex] = value;
        TIC.InfoSet.set(rowIndex, temp);
    }

    @Override
    public boolean isCellEditable(int row, int column) {
//        if(this.columnNames[column].equals("usex")) {
//            return true;
//        }
//        return false;
        return TIC.ColumnInfo[column].isEditable();
    }

 }
